{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": "<pyecharts.render.display.HTML at 0x217493fcfd0>",
      "text/html": "\n<script>\n    require.config({\n        paths: {\n            'echarts':'https://assets.pyecharts.org/assets/v5/echarts.min'\n        }\n    });\n</script>\n\n        <div id=\"53fac67b13b340e7bfd2d3414304a5b1\" style=\"width:900px; height:500px;\"></div>\n\n<script>\n        require(['echarts'], function(echarts) {\n                var chart_53fac67b13b340e7bfd2d3414304a5b1 = echarts.init(\n                    document.getElementById('53fac67b13b340e7bfd2d3414304a5b1'), 'white', {renderer: 'canvas'});\n                var option_53fac67b13b340e7bfd2d3414304a5b1 = {\n    \"animation\": true,\n    \"animationThreshold\": 2000,\n    \"animationDuration\": 1000,\n    \"animationEasing\": \"cubicOut\",\n    \"animationDelay\": 0,\n    \"animationDurationUpdate\": 300,\n    \"animationEasingUpdate\": \"cubicOut\",\n    \"animationDelayUpdate\": 0,\n    \"aria\": {\n        \"enabled\": false\n    },\n    \"color\": [\n        \"#5470c6\",\n        \"#91cc75\",\n        \"#fac858\",\n        \"#ee6666\",\n        \"#73c0de\",\n        \"#3ba272\",\n        \"#fc8452\",\n        \"#9a60b4\",\n        \"#ea7ccc\"\n    ],\n    \"series\": [\n        {\n            \"type\": \"line\",\n            \"name\": \"\\u7535\\u5546\\u6e20\\u9053\",\n            \"connectNulls\": false,\n            \"xAxisIndex\": 0,\n            \"symbolSize\": 4,\n            \"showSymbol\": true,\n            \"smooth\": false,\n            \"clip\": true,\n            \"step\": false,\n            \"stackStrategy\": \"samesign\",\n            \"data\": [\n                [\n                    \"Apple\",\n                    123\n                ],\n                [\n                    \"Huawei\",\n                    153\n                ],\n                [\n                    \"Xiaomi\",\n                    89\n                ],\n                [\n                    \"Oppo\",\n                    107\n                ],\n                [\n                    \"Vivo\",\n                    98\n                ],\n                [\n                    \"Meizu\",\n                    23\n                ]\n            ],\n            \"hoverAnimation\": true,\n            \"label\": {\n                \"show\": true,\n                \"margin\": 8,\n                \"valueAnimation\": false\n            },\n            \"logBase\": 10,\n            \"seriesLayoutBy\": \"column\",\n            \"lineStyle\": {\n                \"show\": true,\n                \"width\": 1,\n                \"opacity\": 1,\n                \"curveness\": 0,\n                \"type\": \"solid\"\n            },\n            \"areaStyle\": {\n                \"opacity\": 0\n            },\n            \"markLine\": {\n                \"silent\": false,\n                \"precision\": 2,\n                \"label\": {\n                    \"show\": true,\n                    \"margin\": 8,\n                    \"valueAnimation\": false\n                },\n                \"data\": [\n                    {\n                        \"type\": \"average\"\n                    }\n                ]\n            },\n            \"zlevel\": 0,\n            \"z\": 0\n        },\n        {\n            \"type\": \"line\",\n            \"name\": \"\\u95e8\\u5e97\",\n            \"connectNulls\": false,\n            \"xAxisIndex\": 0,\n            \"symbolSize\": 4,\n            \"showSymbol\": true,\n            \"smooth\": true,\n            \"clip\": true,\n            \"step\": false,\n            \"stackStrategy\": \"samesign\",\n            \"data\": [\n                [\n                    \"Apple\",\n                    56\n                ],\n                [\n                    \"Huawei\",\n                    77\n                ],\n                [\n                    \"Xiaomi\",\n                    93\n                ],\n                [\n                    \"Oppo\",\n                    68\n                ],\n                [\n                    \"Vivo\",\n                    45\n                ],\n                [\n                    \"Meizu\",\n                    67\n                ]\n            ],\n            \"hoverAnimation\": true,\n            \"label\": {\n                \"show\": true,\n                \"margin\": 8,\n                \"valueAnimation\": false\n            },\n            \"logBase\": 10,\n            \"seriesLayoutBy\": \"column\",\n            \"lineStyle\": {\n                \"show\": true,\n                \"width\": 1,\n                \"opacity\": 1,\n                \"curveness\": 0,\n                \"type\": \"solid\"\n            },\n            \"areaStyle\": {\n                \"opacity\": 0\n            },\n            \"markPoint\": {\n                \"label\": {\n                    \"show\": true,\n                    \"position\": \"inside\",\n                    \"color\": \"#fff\",\n                    \"margin\": 8,\n                    \"valueAnimation\": false\n                },\n                \"data\": [\n                    {\n                        \"name\": \"\\u81ea\\u5b9a\\u4e49\\u6807\\u8bb0\\u70b9\",\n                        \"coord\": [\n                            \"Xiaomi\",\n                            93\n                        ],\n                        \"value\": 93\n                    }\n                ]\n            },\n            \"zlevel\": 0,\n            \"z\": 0\n        }\n    ],\n    \"legend\": [\n        {\n            \"data\": [\n                \"\\u7535\\u5546\\u6e20\\u9053\",\n                \"\\u95e8\\u5e97\"\n            ],\n            \"selected\": {},\n            \"show\": true,\n            \"padding\": 5,\n            \"itemGap\": 10,\n            \"itemWidth\": 25,\n            \"itemHeight\": 14,\n            \"backgroundColor\": \"transparent\",\n            \"borderColor\": \"#ccc\",\n            \"borderRadius\": 0,\n            \"pageButtonItemGap\": 5,\n            \"pageButtonPosition\": \"end\",\n            \"pageFormatter\": \"{current}/{total}\",\n            \"pageIconColor\": \"#2f4554\",\n            \"pageIconInactiveColor\": \"#aaa\",\n            \"pageIconSize\": 15,\n            \"animationDurationUpdate\": 800,\n            \"selector\": false,\n            \"selectorPosition\": \"auto\",\n            \"selectorItemGap\": 7,\n            \"selectorButtonGap\": 10\n        }\n    ],\n    \"tooltip\": {\n        \"show\": true,\n        \"trigger\": \"item\",\n        \"triggerOn\": \"mousemove|click\",\n        \"axisPointer\": {\n            \"type\": \"line\"\n        },\n        \"showContent\": true,\n        \"alwaysShowContent\": false,\n        \"showDelay\": 0,\n        \"hideDelay\": 100,\n        \"enterable\": false,\n        \"confine\": false,\n        \"appendToBody\": false,\n        \"transitionDuration\": 0.4,\n        \"textStyle\": {\n            \"fontSize\": 14\n        },\n        \"borderWidth\": 0,\n        \"padding\": 5,\n        \"order\": \"seriesAsc\"\n    },\n    \"xAxis\": [\n        {\n            \"show\": true,\n            \"scale\": false,\n            \"nameLocation\": \"end\",\n            \"nameGap\": 15,\n            \"gridIndex\": 0,\n            \"inverse\": false,\n            \"offset\": 0,\n            \"splitNumber\": 5,\n            \"minInterval\": 0,\n            \"splitLine\": {\n                \"show\": true,\n                \"lineStyle\": {\n                    \"show\": true,\n                    \"width\": 1,\n                    \"opacity\": 1,\n                    \"curveness\": 0,\n                    \"type\": \"solid\"\n                }\n            },\n            \"animation\": true,\n            \"animationThreshold\": 2000,\n            \"animationDuration\": 1000,\n            \"animationEasing\": \"cubicOut\",\n            \"animationDelay\": 0,\n            \"animationDurationUpdate\": 300,\n            \"animationEasingUpdate\": \"cubicOut\",\n            \"animationDelayUpdate\": 0,\n            \"data\": [\n                \"Apple\",\n                \"Huawei\",\n                \"Xiaomi\",\n                \"Oppo\",\n                \"Vivo\",\n                \"Meizu\"\n            ]\n        }\n    ],\n    \"yAxis\": [\n        {\n            \"show\": true,\n            \"scale\": false,\n            \"nameLocation\": \"end\",\n            \"nameGap\": 15,\n            \"gridIndex\": 0,\n            \"inverse\": false,\n            \"offset\": 0,\n            \"splitNumber\": 5,\n            \"minInterval\": 0,\n            \"splitLine\": {\n                \"show\": true,\n                \"lineStyle\": {\n                    \"show\": true,\n                    \"width\": 1,\n                    \"opacity\": 1,\n                    \"curveness\": 0,\n                    \"type\": \"solid\"\n                }\n            },\n            \"animation\": true,\n            \"animationThreshold\": 2000,\n            \"animationDuration\": 1000,\n            \"animationEasing\": \"cubicOut\",\n            \"animationDelay\": 0,\n            \"animationDurationUpdate\": 300,\n            \"animationEasingUpdate\": \"cubicOut\",\n            \"animationDelayUpdate\": 0\n        }\n    ],\n    \"title\": [\n        {\n            \"show\": true,\n            \"text\": \"Line-\\u57fa\\u672c\\u793a\\u4f8b\",\n            \"target\": \"blank\",\n            \"subtext\": \"\\u6211\\u662f\\u526f\\u6807\\u9898\",\n            \"subtarget\": \"blank\",\n            \"padding\": 5,\n            \"itemGap\": 10,\n            \"textAlign\": \"auto\",\n            \"textVerticalAlign\": \"auto\",\n            \"triggerEvent\": false\n        }\n    ]\n};\n                chart_53fac67b13b340e7bfd2d3414304a5b1.setOption(option_53fac67b13b340e7bfd2d3414304a5b1);\n        });\n    </script>\n"
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts.charts import Line\n",
    "from pyecharts import options as opts\n",
    "\n",
    "# 示例数据\n",
    "cate = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu']\n",
    "data1 = [123, 153, 89, 107, 98, 23]\n",
    "data2 = [56, 77, 93, 68, 45, 67]\n",
    "\n",
    "\"\"\"\n",
    "折线图示例:\n",
    "1. is_smooth 折线 OR 平滑\n",
    "2. markline_opts 标记线 OR 标记点\n",
    "\"\"\"\n",
    "line = (Line()\n",
    "        .add_xaxis(cate)\n",
    "        .add_yaxis('电商渠道', data1,\n",
    "                   markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_=\"average\")]))\n",
    "        .add_yaxis('门店', data2,\n",
    "                   is_smooth=True,\n",
    "                   markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(name=\"自定义标记点\",\n",
    "                                                                              coord=[cate[2], data2[2]],\n",
    "                                                                              value=data2[2])]))\n",
    "        .set_global_opts(title_opts=opts.TitleOpts(title=\"Line-基本示例\", subtitle=\"我是副标题\"))\n",
    "        )\n",
    "\n",
    "line.render_notebook()\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
